
Security News
/Research
npm Phishing Email Targets Developers with Typosquatted Domain
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.
github-base
Advanced tools
JavaScript wrapper that greatly simplifies working with GitHub's API.
Install with npm:
$ npm install --save github-base
Heads up!
This lib was completely refactored in v0.2.0
. Please see the API documentation for more details.
About
This library provides the necessary methods for creating your own GitHub API library or more specific functionality built on top of these methods.
GET
, PUT
, POST
, DELETE
, PATCH
request('GET', path, data, cb)
.get()
requests until the page of data has been retrieved.request('DEL', path, data, cb)
request('PATCH', path, data, cb)
request('POST', path, data, cb)
request('PUT', path, data, cb)
var GitHub = require('github-base');
var github = new GitHub({
username: YOUR_USERNAME,
password: YOUR_PASSWORD,
});
// or
var github = new GitHub({
token: YOUR_TOKEN
});
// or
var github = new GitHub({
bearer: YOUR_JWT
});
Every other GitHub API library I found either had a huge dependency tree, tries to be everything to everyone, was too bloated with boilerplace code, was too opinionated or not maintained.
Create an instance of GitHub
with the given options.
Params
options
{Object}Example
var GitHub = require('github-base');
var github = new GitHub(options);
Uses simple-get to make a single request to the GitHub API, based on the provided settings. Supports any of the GitHub API VERBs:
GET
PUT
POST
DELETE
PATCH
Params
method
{String}: The http VERB to useurl
{String}: GitHub API URL to use.options
{Options}: Request options.cb
{Function}Example
//example..request
github.request('GET', '/user/orgs', function (err, res) {
//=> array of orgs
});
Makes a single GET
request to the GitHub API based on the provided settings.
Params
path
{String}: path to append to the GitHub API URL.options
{Options}: Request options.cb
{Function}Example
// get orgs for the authenticated user
github.get('/user/orgs', function (err, res) {
//=> array of orgs
});
// get gists for the authenticated user
github.get('/gists', function (err, res) {
//=> array of gists
});
Performs a request using simple-get, and then if necessary requests additional paged content based on the response. Data from all pages are concatenated together and buffered until the last page of data has been retrieved.
Params
path
{String}: path to append to the GitHub API URL.cb
{Function}Example
// get all repos for the authenticated user
var url = '/user/repos?type=all&per_page=1000&sort=updated';
github.paged(url, function(err, res) {
console.log(res);
});
Makes a single DELETE
request to the GitHub API based on the provided settings.
Params
path
{String}: path to append to the GitHub API URL.options
{Options}: Request options.cb
{Function}Example
// un-follow someone
github.del('/user/following/someoneelse', function(err, res) {
console.log(res);
});
Makes a single PATCH
request to the GitHub API based on the provided settings.
Params
path
{String}: path to append to the GitHub API URL.options
{Options}: Request options.cb
{Function}Example
// update a gist
var fs = require('fs');
var opts = {files: {'readme.md': { content: '# My Readme...' }}};
github.patch('/gists/bd139161a425896f35f8', opts, function(err, res) {
console.log(err, res);
});
Makes a single POST
request to the GitHub API based on the provided settings.
Params
path
{String}: path to append to the GitHub API URL.options
{Options}: Request options.cb
{Function}Example
// create a new repo
var opts = { name: 'new-repo-name' };
github.post('/user/repos', opts, function(err, res) {
console.log(res);
});
Makes a single PUT
request to the GitHub API based on the provided settings.
Params
path
{String}: path to append to the GitHub API URL.options
{Options}: Request options.cb
{Function}Example
// follow someone
github.put('/user/following/jonschlinkert', function(err, res) {
console.log(res);
});
Static method for inheriting the prototype and static methods of the Base
class. This method greatly simplifies the process of creating inheritance-based applications. See static-extend for more details.
Params
Ctor
{Function}: constructor to extendExample
var GitHub = require('github-base');
function MyApp() {
GitHub.call(this);
}
GitHub.extend(MyApp);
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Commits | Contributor |
---|---|
31 | jonschlinkert |
7 | tunnckoCore |
6 | doowb |
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Jon Schlinkert
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.4.3, on April 06, 2017.
[0.5.4] - 2017-04-19
FAQs
Low-level methods for working with the GitHub API in node.js/JavaScript.
The npm package github-base receives a total of 3,165 weekly downloads. As such, github-base popularity was classified as popular.
We found that github-base demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.
Security News
Knip hits 500 releases with v5.62.0, refining TypeScript config detection and updating plugins as monthly npm downloads approach 12M.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.